<?php

declare(strict_types=1);

namespace App\Models;

class AgentRevenue extends Base
{
    /**
     * 明细类型: 下单
     */
    const TYPE_PLACE_ORDER = 1;

    /**
     * 明细类型: 下单-不可提现
     */
    const TYPE_PLACE_ORDER_UNEXTRACTABLE = 2;

    /**
     * 明细类型: 撤单
     */
    const TYPE_CANCEL_ORDER = 3;

    /**
     * 明细类型: 撤单-不可提现
     */
    const TYPE_CANCEL_ORDER_UNEXTRACTABLE = 4;

    /**
     * 明细类型: 佣金
     */
    const TYPE_COMMISSION = 5;

    /**
     * 明细类型: 撤销佣金
     */
    const TYPE_REVOCATION_COMMISSION = 6;

    /**
     * 明细类型: 直接邀请 奖励
     */
    const TYPE_DIRECT_INVITATION_REWARD = 7;

    /**
     * 明细类型: 间接邀请 奖励
     */
    const TYPE_INDIRECT_INVITATION_REWARD = 8;

    /**
     * 明细类型: 撤销直接邀请奖励
     */
    const TYPE_REVOCATION_DIRECT_INVITATION_REWARD = 9;

    /**
     * 明细类型: 撤销间接邀请奖励
     */
    const TYPE_REVOCATION_INDIRECT_INVITATION_REWARD = 10;

    /**
     * 明细类型: 培养奖励
     */
    const TYPE_CULTIVATE_REWARDS = 11;

    /**
     * 明细类型: 撤销培养奖励
     */
    const TYPE_REVOCATION_CULTIVATE_REWARDS = 12;

    /**
     * 明细类型: 换货运费补偿
     */
    const TYPE_EXCHANGE_FREIGHT_COMPENSATION = 13;

    /**
     * 明细类型: 补偿
     */
    const TYPE_MAKE_UP = 14;

    /**
     * 明细类型: 退款 退货
     */
    const TYPE_REFUND = 15;

    /**
     * 明细类型: 退款 退货-不可提现
     */
    const TYPE_REFUND_UNEXTRACTABLE = 16;

    /**
     * 明细类型: 退款 退货撤销佣金
     */
    const TYPE_REFUND_REVOCATION_COMMISSION = 17;

    /**
     * 明细类型: 退货撤销奖励 (直接邀请)
     */
    const TYPE_REFUND_REVOCATION_DIRECT_INVITATION_REWARD = 18;

    /**
     * 明细类型: 退货撤销奖励 (间接邀请)
     */
    const TYPE_REFUND_REVOCATION_INDIRECT_INVITATION_REWARD = 19;

    /**
     * 明细类型: 充值
     */
    const TYPE_TOP_UP = 20;

    /**
     * 明细类型: 充值-不可提现 (仅仅是充值的那部分,赠送的金额 另外类型)
     */
    const TYPE_TOP_UP_UNEXTRACTABLE = 21;

    /**
     * 明细类型: 充值赠送的金额 (不可提现)
     */
    const TYPE_TOP_UP_GIVE_AWAY = 22;

    /**
     * 明细类型: 提现
     */
    const TYPE_EXTRACT = 23;

    /**
     * 明细类型: 提现拒绝
     */
    const TYPE_EXTRACT_REFUSE = 24;

    /**
     * 明细类型: 每日下单活动奖励
     */
    const TYPE_DAILY_ORDER_REWARD = 25;

    /**
     * 明细类型: 每月下单活动奖励
     */
    const TYPE_ORDER_REWARD_PER_MONTH = 26;

    /**
     * 明细类型: 划拨
     */
    const TYPE_TRANSFER = 27;

    /**
     * 明细类型: 管理员减少不可提现余额
     */
    const TYPE_ADMIN_UNEXTRACTABLE_DECREASE = 28;

    /**
     * 明细类型: 管理员增加不可提现余额
     */
    const TYPE_ADMIN_UNEXTRACTABLE_INCREASE = 29;

    /**
     * 明细类型: 管理员减少可提现余额
     */
    const TYPE_ADMIN_BALANCE_DECREASE = 30;

    /**
     * 明细类型: 管理员增加可提现余额
     */
    const TYPE_ADMIN_BALANCE_INCREASE = 31;

    /**
     * 明细类型: 撤销每日下单活动奖励
     */
    const TYPE_REVOCATION_DAILY_ORDER_REWARD = 32;

    /**
     * 明细类型: 撤销每月下单活动奖励
     */
    const TYPE_REVOCATION_ORDER_REWARD_PER_MONTH = 33;

    /**
     * 明细类型: 撤单-退运费
     */
    const TYPE_CANCEL_ORDER_FREIGHT = 34;

    /**
     * 明细类型: 撤单-退运费(不可提现)
     */
    const TYPE_CANCEL_ORDER_FREIGHT_UNEXTRACTABLE = 35;

    /**
     * 明细类型
     */
    const TYPE_MAP = [
        self::TYPE_PLACE_ORDER => '下单',
        self::TYPE_PLACE_ORDER_UNEXTRACTABLE => '下单-不可提现',
        self::TYPE_CANCEL_ORDER => '撤单',
        self::TYPE_CANCEL_ORDER_UNEXTRACTABLE => '撤单-不可提现',
        self::TYPE_COMMISSION => '佣金',
        self::TYPE_REVOCATION_COMMISSION => '撤销佣金',
        self::TYPE_DIRECT_INVITATION_REWARD => '直接邀请 奖励',
        self::TYPE_INDIRECT_INVITATION_REWARD => '间接邀请 奖励',
        self::TYPE_REVOCATION_DIRECT_INVITATION_REWARD => '撤销直接邀请奖励',
        self::TYPE_REVOCATION_INDIRECT_INVITATION_REWARD => '撤销间接邀请奖励',
        self::TYPE_CULTIVATE_REWARDS => '培养奖励',
        self::TYPE_REVOCATION_CULTIVATE_REWARDS => '撤销培养奖励',
        self::TYPE_EXCHANGE_FREIGHT_COMPENSATION => '换货运费补偿',
        self::TYPE_MAKE_UP => '补偿',
        self::TYPE_REFUND => '退货退款',
        self::TYPE_REFUND_UNEXTRACTABLE => '退货退款-不可提现',
        self::TYPE_REFUND_REVOCATION_COMMISSION => '退货退款撤销佣金',
        self::TYPE_REFUND_REVOCATION_DIRECT_INVITATION_REWARD => '退货撤销奖励 (直接邀请)',
        self::TYPE_REFUND_REVOCATION_INDIRECT_INVITATION_REWARD => '退货撤销奖励 (间接邀请)',
        self::TYPE_TOP_UP => '充值',
        self::TYPE_TOP_UP_UNEXTRACTABLE => '充值-不可提现',
        self::TYPE_TOP_UP_GIVE_AWAY => '充返金额 (不可提现)',
        self::TYPE_EXTRACT => '提现',
        self::TYPE_EXTRACT_REFUSE => '提现拒绝',
        self::TYPE_DAILY_ORDER_REWARD => '每日下单奖励',
        self::TYPE_ORDER_REWARD_PER_MONTH => '每月下单奖励',
        self::TYPE_TRANSFER => '划拨',
        self::TYPE_ADMIN_UNEXTRACTABLE_DECREASE => '平台减少不可提现余额',
        self::TYPE_ADMIN_UNEXTRACTABLE_INCREASE => '平台增加不可提现余额',
        self::TYPE_ADMIN_BALANCE_DECREASE => '平台减少余额',
        self::TYPE_ADMIN_BALANCE_INCREASE => '平台增加余额',
        self::TYPE_REVOCATION_DAILY_ORDER_REWARD => '撤销每日下单活动奖励',
        self::TYPE_REVOCATION_ORDER_REWARD_PER_MONTH => '撤销每月下单活动奖励',
        self::TYPE_CANCEL_ORDER_FREIGHT => '撤单-退运费',
        self::TYPE_CANCEL_ORDER_FREIGHT_UNEXTRACTABLE => '撤单-退运费(不可提现)',
    ];

    /**
     * 收支类型: 收入
     */
    const REVENUES_TYPE_INCOME = 1;

    /**
     * 收支类型: 支出
     */
    const REVENUES_TYPE_EXPENDITURE = 2;

    /**
     * 佣金系列
     */
    const TYPE_COMMISSION_LIST = [
        self::TYPE_COMMISSION,
        self::TYPE_REVOCATION_COMMISSION,
        self::TYPE_REFUND_REVOCATION_COMMISSION
    ];

    /**
     * 奖金系列
     */
    const TYPE_REWARD_LIST = [
        self::TYPE_DIRECT_INVITATION_REWARD,
        self::TYPE_INDIRECT_INVITATION_REWARD,
        self::TYPE_REVOCATION_DIRECT_INVITATION_REWARD,
        self::TYPE_REVOCATION_INDIRECT_INVITATION_REWARD,
        self::TYPE_CULTIVATE_REWARDS,
        self::TYPE_REVOCATION_CULTIVATE_REWARDS,
        self::TYPE_REFUND_REVOCATION_DIRECT_INVITATION_REWARD,
        self::TYPE_REFUND_REVOCATION_INDIRECT_INVITATION_REWARD,
        self::TYPE_DAILY_ORDER_REWARD,
        self::TYPE_ORDER_REWARD_PER_MONTH,
        self::TYPE_REVOCATION_DAILY_ORDER_REWARD,
        self::TYPE_REVOCATION_ORDER_REWARD_PER_MONTH,
    ];

    public function source()
    {
        return $this->morphTo();
    }

    public function agent()
    {
        return $this->belongsTo(Agent::class);
    }
}
